package com.java.utils;

/**
* @ClassName: UserSession
* @Description: 记录用户登陆信息
 */
public class UserSession {

	private static UserSession instance = new UserSession();

	private UserSession() {
	}

	private Integer userId;

	private String userName;

	private String userPassword;

	public static UserSession getInstance() {
		return instance;
	}

	/**
	 * 预设/更改登陆信息
	 */
	public void setVal(int userId, String userName, String userPassword) {
		this.userId = userId;
		this.userName = userName;
		this.userPassword = userPassword;
	}

	/**
	 * 是否登陆
	 */
	public boolean isLogin() {
		if (null == userId) {
			return false;
		}
		return true;
	}

	/**
	 * 退出登陆
	 */
	public void logout() {
		this.userId = null;
		this.userName = null;
	}

	/**
	 * 常规get&set
	 */
	public Integer getUserId() {
		return userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getUserPassword() {
		return userPassword;
	}

	public void setUserPassword(String userPassword) {
		this.userPassword = userPassword;
	}

}
